<!--借阅-->

<!--点击借阅按钮进入此页面-->
<html>
<head>
    <meta charset="utf-8">
    <!--<meta http-equiv="X-UA-Compatible" content="IE=edge">-->
    <!--<meta name="viewport" content="width=device-width, initial-scale=1">-->
    <title>借阅《 ${book.name}》</title>
    <!--<link rel="stylesheet" href="css/bootstrap.min.css">-->
    <!--<script src="js/jquery-3.3.1.js"></script>-->
    <!--<script src="js/bootstrap.min.js" ></script>-->
    <!--<script src="js/getParameter.js"></script>-->
    <style>
        body{
            background-color: rgb(240,242,245);
        }
    </style>

</head>
<body>

<!--<div class="col-xs-6 col-md-offset-3" style="position: relative;top: 25%">-->
    <!--<div class="panel panel-primary">-->
        <!--<div class="panel-heading">-->
            <!--<h3 class="panel-title" id="btitle"></h3>-->
        <!--</div>-->
        <!--<div class="panel-body">-->
            <!--<form action="lendbookdo.html?id=${book.bookId}" method="post" id="lendbook" >-->
                <!--<div class="input-group">-->
                    <!--<span  class="input-group-addon">书名</span>-->
                    <!--<input type="text" readonly="readonly" class="form-control" name="name" id="name" value="">-->
                <!--</div>-->
                <!--<br/>-->
                <!--<div class="input-group">-->
                    <!--<span class="input-group-addon">读者证号</span>-->
                    <!--<input type="text" class="form-control" name="readerId" id="readerId" placeholder="借阅人读者证号" >-->
                <!--</div>-->
                <!--<br/>-->
                <!--<input type="submit" value="确定" class="btn btn-success btn-sm" class="text-left">-->

            <!--</form>-->
        <!--</div>-->
    <!--</div>-->

<!--</div>-->
<div class="col-xs-6 col-md-offset-3" style="position: relative;top: 25%">
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title" id="btitle"></h3>
        </div>
        <div class="panel-body">
            <form id="lendbook" >
                <input type="hidden" id="page" name="page">
                <div class="input-group">
                    <span  class="input-group-addon">书名</span>
                    <input type="text" readonly class="form-control" name="name" id="name" value="">
                </div>
                <br/>
                <div class="input-group">
                    <span class="input-group-addon">读者证号</span>
                    <input type="text" class="form-control" name="readerId" id="readerId" placeholder="借阅人读者证号" >
                </div>
                <br/>
                <input type="submit" value="确定" class="btn btn-success btn-sm" class="text-left">
            </form>
        </div>
    </div>

</div>

</body>
<script>
    $(function () {
        $("#page").val($.cookie("page"));
        $("#name").val($.cookie("bookName"));
        $("#btitle").html("借阅:"+$.cookie("bookName"));
        $.removeCookie("page");
        $.removeCookie("bookName");
    })
    function mySubmit(flag){
        return flag;
    }
    //点击确定借阅按钮，把借阅是否成功的结果返回给admin_books.html！！
    $("#lendbook").submit(function () {
        if($("#name").val()==''||$("#readerId").val()==''){
            alert("请填入完整图书信息！");
            return false;
        }
        if($("#readerId").val().length>10) {
            alert("读者id错误")
            return false;
        }
        $.ajax({
            type:"post",
            dataType:"json",
            url:"user/lendBook",
            data:$("#lendbook").serialize(),
            success:function (data) {
                if(data==0)
                    alert("读者id错误!")
                else if(data == 1)
                    $("#middle").load("admin_books.html");
                else if(data == 2)
                    $("#middle").load("reader_book_query.html");
            }

        })
        return false;
    })
</script>
</html>
